using UnityEngine;
using QFramework;
using UnityEngine.UI;
using System;

// 1.请在菜单 编辑器扩展/Namespace Settings 里设置命名空间
// 2.命名空间更改后，生成代码之后，需要把逻辑代码文件（非 Designer）的命名空间手动更改
namespace QFramework.Example
{
	public partial class FloattingTextController : ViewController
	{
		void Start()
		{
			// Code Here
			// Floatting.Hide();
		}

		public void OnPlay(Vector2 pos, string content)
		{
			var floatting = Floatting.InstantiateWithParent(transform).Position(pos).Show();

			Text hp = floatting.GetComponentInChildren<Text>();
			hp.text = content;

			ActionKit.Sequence().Lerp(0, 0.5f, 0.5f, (p) =>
						{
							floatting.PositionY(pos.y + p * 0.25f);
							hp.LocalScaleX(Mathf.Clamp01(p * 8));
							hp.LocalScaleY(Mathf.Clamp01(p * 8));
						})
						.Delay(0.5f)
						.Lerp(1, 0, 0.3f, (p) =>
						{
							hp.ColorAlpha(p);
						}, () =>
						{
							floatting.DestroyGameObjGracefully();
						}).Start(hp);

		}
	}
}
